/*
 * Wazuh Vulnerability Scanner - Unit Tests
 * Copyright (C) 2015, Wazuh Inc.
 * September 21, 2023.
 *
 * This program is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General Public
 * License (version 2) as published by the FSF - Free Software
 * Foundation.
 */

#include "scanDispatcher_test.hpp"
#include "databaseFeedManager/eventContext.hpp"
#include "databaseFeedManager/scanDispatcher.hpp"
#include <memory>
#include <string>
#include <vector>

/*
 * @brief Test instantiation of the ScanDispatcher class.
 */
TEST_F(ScanDispatcherTest, TestInstantiationOfTheScanDispatcherClass)
{
    // Instantiation of the ScanDispatcher class.
    EXPECT_NO_THROW(std::make_shared<ScanDispatcher>());
}

/*
 * @brief Test handleRequest of the ScanDispatcher class.
 */
TEST_F(ScanDispatcherTest, TestHandleRequest)
{
    std::vector<char> message;
    nlohmann::json resource;
    auto cvesDatabase = std::make_unique<Utils::RocksDBWrapper>("temp");
    auto eventContext = std::make_shared<EventContext>(
        EventContext {.message = message, .resource = resource, .feedDatabase = cvesDatabase.get()});

    std::shared_ptr<ScanDispatcher> scanDispatcher;

    // Instantiation of the ScanDispatcher class.
    EXPECT_NO_THROW(scanDispatcher = std::make_shared<ScanDispatcher>());

    // HandleRequest
    EXPECT_NO_THROW(scanDispatcher->handleRequest(eventContext));
}
